package calorie.com.calorie.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lxh.baselibray.dialog.AlertDialog;
import com.lxh.baselibray.util.SizeUtils;
import com.lxh.baselibray.util.TimeUtils;

import java.text.SimpleDateFormat;
import java.util.List;

import calorie.com.calorie.R;
import calorie.com.calorie.response.ProfitRecordResponce;
import retrofit2.http.HEAD;


public class ProfitRecodAdapter extends BaseQuickAdapter<ProfitRecordResponce.DataBean, BaseViewHolder> {
    private Context context;
    AlertDialog alertDialog = null;

    public ProfitRecodAdapter(Context context, int layoutResId, @Nullable List<ProfitRecordResponce.DataBean> data) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, ProfitRecordResponce.DataBean item) {
        int type = item.getType();//1为糖果奖励，2为运动奖励，3为管理奖励,4为推荐奖励

        String profitText = "";
        switch (type) {
            case 1:
                profitText = "空投奖励：";
                break;
            case 2:
                profitText = "运动奖励：";
                break;
            case 3:
                profitText = "管理奖励：";
                break;
            case 4:
                profitText = "推荐奖励：";
                break;
        }

        helper.setText(R.id.tv_profit, profitText + item.getTokenNum() + item.getTokenType())
                .setText(R.id.tv_time, TimeUtils.millis2String(item.getTime(), new SimpleDateFormat("yyyy-MM-dd")));
//        View tv_profit = helper.itemView.findViewById(R.id.recy_item);

//        tv_profit.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                View convertView = LayoutInflater.from(context).inflate(R.layout.dialog_remind, null);
//                AlertDialog.Builder builder = new AlertDialog.Builder(context).addDefaultAnimation().setCancelable(true)
//                        .setContentView(convertView)
//                        .setWidthAndHeight(SizeUtils.dp2px(context, 279), SizeUtils.dp2px(context, 200))
//                        .setOnClickListener(R.id.bt_start_download, new View.OnClickListener() {
//                            @Override
//                            public void onClick(View v) {
//                                alertDialog.dismiss();
//                            }
//                        });
//
//                convertView.findViewById(R.id.msg).setVisibility(View.GONE);
//                convertView.findViewById(R.id.view_line).setVisibility(View.GONE);
//
//                TextView resultView = convertView.findViewById(R.id.resultView);
//                resultView.setText(item.getRemarks());
//
//                alertDialog = builder.create();
//                alertDialog.setCancelable(false);
//
//                alertDialog.show();
//            }
//        });




    }
}
